package com.volunteer.service.Impl;

import com.volunteer.mapper.UserLoginMapper;
import com.volunteer.model.UserLogin;
import com.volunteer.service.UserLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class UserLoginServiceImpl implements UserLoginService {
    @Autowired
    private UserLoginMapper userLoginMapper;

    @Override
    public int add(String token, Long userId) {
        UserLogin userLogin = new UserLogin();
        userLogin.setUserId(userId);
        userLogin.setToken(token);
        userLogin.setCreateTime(new Date());
        return userLoginMapper.insertSelective(userLogin);
    }

    @Override
    public List<String> getTokenByUserId(Long userId) {
        return userLoginMapper.selectByUserId(userId);
    }

    @Override
    public int delByUserId(Long userId) {
        return userLoginMapper.deleteByUserId(userId);
    }
}
